package org.example.tree;

/**
 * Author: wu-meng
 * Time: 2024.12.12
 * 二叉树的最大深度
 */
public class Solution37 {

    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        } else {
            int leftDepth = maxDepth(root.left);
            int rightDepth = maxDepth(root.right);
            return Math.max(leftDepth, rightDepth) + 1;
        }
    }

}
